<?xml version="1.0" encoding="utf-8"?>
<AggregatorItems tfsServerUrl="http://tfs2010dev:8080/tfs" >
  
  <!--Add up the estimated work on the task-->
  <AggregatorItem operationType="Numeric" operation="Sum" linkType="Self" workItemType="Task">
	  <TargetItem name="Estimated Work"/>
	  <SourceItem name="Estimated Dev Work"/>
	  <SourceItem name="Estimated Test Work"/>
  </AggregatorItem>
  
  <!--Add up the actual remaining work on the Task-->
	<AggregatorItem operationType="Numeric" operation="Sum" linkType="Self" workItemType="Task">
		<TargetItem name="Remaining Work"/>
		<SourceItem name="Remaining Dev Work"/>
		<SourceItem name="Remaining Test Work"/>
	</AggregatorItem>
  
  <!--Add the time from the task up to the parent (Bug or PBI)-->
  <AggregatorItem operation="Sum" linkType="Parent" linkLevel="1" workItemType="Task">
    <TargetItem name="Total Work Remaining"/>
    <SourceItem name="Remaining Dev Work"/>
    <SourceItem name="Remaining Test Work"/>
  </AggregatorItem>

  <!--Add the time from the task up to the parent (Bug or PBI)-->
  <AggregatorItem operation="Sum" linkType="Parent" linkLevel="1" workItemType="Task">
    <TargetItem name="Total Estimate"/>
    <SourceItem name="Estimated Dev Work"/>
    <SourceItem name="Estimated Test Work"/>
  </AggregatorItem>

  <!--Sum up all the dev estimates to the sprint-->
  <AggregatorItem operation="Sum" linkType="Parent" linkLevel="2" workItemType="Task">
    <Conditions>
      <Condition leftField="Finish Date" operator="GreaterThan" rightValue="$NOW$"/>
    </Conditions>
    <TargetItem name="Dev Estimate"/>
    <SourceItem name="Estimated Dev Work"/>
  </AggregatorItem>

  <!--Sum up all the test estimates to the sprint-->
  <AggregatorItem operation="Sum" linkType="Parent" linkLevel="2" workItemType="Task">
    <Conditions>
      <Condition leftField="Finish Date" operator="GreaterThan" rightValue="$NOW$"/>
    </Conditions>
    <TargetItem name="Test Estimate"/>
    <SourceItem name="Estimated Test Work"/>
  </AggregatorItem>

  <!--Get the total of estimated work on the Sprint-->
  <AggregatorItem operationType="Numeric" operation="Sum" linkType="Parent" linkLevel="2" workItemType="Task">
    <Conditions>
      <Condition leftField="Finish Date" operator="GreaterThan" rightValue="$NOW$"/>
    </Conditions>
    <TargetItem name="Total Estimate"/>
    <SourceItem name="Estimated Dev Work"/>
    <SourceItem name="Estimated Test Work"/>
  </AggregatorItem>

  <!--Add up the capacity on the Sprint-->
  <AggregatorItem operationType="Numeric" operation="Sum" linkType="Self" workItemType="Sprint">
    <TargetItem name="Total Capacity"/>
    <SourceItem name="Dev Capacity"/>
    <SourceItem name="SQA Capacity"/>
  </AggregatorItem>

  <!--When all Tasks are done being worked on set the parent (Bug or PBI) to Done (unless it is Removed)-->
  <AggregatorItem operationType="String" linkType="Parent" linkLevel="1" workItemType="Task">
    <Mappings>      
      <Mapping targetValue="Done" inclusive="And">
        <SourceValue>Removed</SourceValue>
        <SourceValue>Done</SourceValue>
      </Mapping>
    </Mappings>
	<Conditions>
      <Condition leftField="State" operator="NotEqualTo" rightValue="Removed"/>
    </Conditions>
    <TargetItem name="State"/>
    <SourceItem name="State"/>
  </AggregatorItem>

  <!--When any Tasks are In Progress set the parent (Bug or PBI) to In Progress-->
  <AggregatorItem operationType="String" linkType="Parent" linkLevel="1" workItemType="Task">
    <Mappings>
      <Mapping targetValue="In Progress" inclusive="Or">
        <SourceValue>In Progress</SourceValue>
        <SourceValue>Ready For Test</SourceValue>
      </Mapping>
    </Mappings>
    <TargetItem name="State"/>
    <SourceItem name="State"/>
  </AggregatorItem>
</AggregatorItems>